/******************************************************************************
 *  Copyright (C) SNDA CORPORATION
 *
 *  ALL RIGHTS RESERVED BY SNDA CORPORATION,  THIS PROGRAM
 *  MUST BE USED SOLELY FOR THE PURPOSE FOR WHICH IT WAS
 *  FURNISHED BY SNDA CORPORATION,  NO PART OF THIS PROGRAM
 *  MAY BE REPRODUCED OR DISCLOSED TO OTHERS,  IN ANY FORM
 *  WITHOUT THE PRIOR WRITTEN PERMISSION OF SNDA CORPORATION.
 *
 *  SNDA CONFIDENTIAL AND PROPRIETARY
 *
 ******************************************************************************
 *  !!! 由MessageCompiler自动生成的代码，请不要手工修改内容。
 *  生成时间: Wed Sep 05 15:37:32 CST 2012
 *****************************************************************************/
#import <Foundation/Foundation.h>
#include <zlib.h>

#define DT_BYTE     1
#define DT_BOOL     2
#define DT_SHORT    3
#define DT_INT      4
#define DT_LONG     5
#define DT_FLOAT    6
#define DT_DOUBLE   7
#define DT_STRING   8

#define IS_NUMBER_TYPE(t)   (t == DT_BYTE || t == DT_BOOL || t == DT_SHORT || \
                             t == DT_INT || t == DT_LONG || \
                             t == DT_FLOAT || t == DT_DOUBLE)
#define IS_STRING_TYPE(t)   (t == DT_STRING)

@interface NSData (NSDataExtension)

// ZLIB
- (NSData *) zlibInflate;
- (NSData *) zlibDeflate;

// GZIP
- (NSData *) gzipInflate;
- (NSData *) gzipDeflate;

@end

@interface IOBuffer : NSObject {
    NSMutableData *dataBuffer;
    NSUInteger limit;
    NSUInteger current;
}

@property (readonly, assign) NSMutableData *dataBuffer;
@property (readonly) NSUInteger limit;
@property (readonly) NSUInteger current;

- (IOBuffer *) init;
- (IOBuffer *) initWithCapacity:(NSUInteger) capacity;
- (void) rewind;
- (void) flip;
- (void) clear;
- (NSUInteger) inputRemaining;
- (NSUInteger) outputRemaining;
- (void) increaseCurrent:(NSUInteger) length;
- (void) extendBufferToContain:(NSUInteger) length;
- (NSUInteger) copyData:(void *) dest;
- (NSUInteger) copyData:(void *) dest :(NSRange) range;

+ (void) reverseBytesOrder:(void*) bytes :(int) size;

+ (short) n2lShort:(short) v;
+ (int) n2lInt:(int) v;
+ (long long) n2lLong:(long long) v;
+ (float) n2lFloat:(float) v;
+ (double) n2lDouble:(double) v;

+ (short) l2nShort:(short) v;
+ (int) l2nInt:(int) v;
+ (long long)l2nLong:(long long) v;
+ (float) l2nFloat:(float) v;
+ (double) l2nDouble:(double) v;

- (void) getBytes:(void *) dest :(NSUInteger) length;
- (Byte) readByte;
- (BOOL) readBoolean;
- (short) readShort;
- (int) readInt;
- (long long) readLong;
- (float) readFloat;
- (double) readDouble;
- (NSString*) readUTF;

- (void) replaceBytes:(const void *) src :(NSRange) range;
- (void) putBytes:(const void *) src :(NSUInteger) length;
- (void) putData:(NSData *) data;
- (void) writeByte:(Byte) v;
- (void) writeBoolean:(BOOL) v;
- (void) writeShort:(short) v;
- (void) writeInt:(int) v;
- (void) writeLong:(long long) v;
- (void) writeFloat:(float) v;
- (void) writeDouble:(double) v;
- (void) writeUTF:(NSString*) v;

@end

@interface MessageBean : NSObject {
	short commandId;
}

@property short commandId;

- (MessageBean *) init;
- (MessageBean *) initWithCommandId:(short) cmdId;

- (void) seriallize:(IOBuffer *) obuffer;
- (void) deseriallize:(IOBuffer *) ibuffer;

- (void) clear;
- (void) printToString:(NSMutableString *) string;
- (void) printToStringWithIndent:(NSMutableString *) string :(int) indentLevel;
- (void) appendIndent:(NSMutableString *) string :(int) indentLevel;

@end

@interface MessageBuffer : NSObject {
}

+ (NSException *) createException:(NSString *)className :(NSException *) cause: (const char *)file :(int)lineNum :(const char *)reasonFormat, ...;
+ (id) getBeanClassByCommandId:(short) commandId;
+ (BOOL) isZippedCommand:(short) commandId;

+ (NSUInteger) pack:(short) commandId :(MessageBean *) bean :(IOBuffer *) obuffer;
+ (MessageBean *) unpack:(short) commandId :(IOBuffer *) ibuffer;

+ (void) packBean:(IOBuffer *) obuffer :(MessageBean *) bean;
+ (void) packBeanList:(IOBuffer *) obuffer :(NSMutableArray *) beanList;
+ (MessageBean *) unpackBean:(IOBuffer *) ibuffer :(id) beanClass;
+ (NSMutableArray *) unpackBeanList:(IOBuffer *) ibuffer :(id) beanClass;

+ (void) writeIsNull:(IOBuffer *) obuffer :(NSObject *)obj;
+ (NSMutableArray *) readArray:(IOBuffer *) ibuffer :(int) dataType;
+ (void) writeArray:(IOBuffer *) obuffer :(NSMutableArray *) ary :(int) dataType;

+ (BOOL) readIsNull:(IOBuffer *) ibuffer;
+ (Byte) readByte:(IOBuffer *) ibuffer;
+ (NSMutableArray *) readByteArray:(IOBuffer *) ibuffer;
+ (BOOL) readBoolean:(IOBuffer *) ibuffer;
+ (NSMutableArray *) readBooleanArray:(IOBuffer *) ibuffer;
+ (short) readShort:(IOBuffer *) ibuffer;
+ (NSMutableArray *) readShortArray:(IOBuffer *) ibuffer;
+ (int) readInteger:(IOBuffer *) ibuffer;
+ (NSMutableArray *) readIntegerArray:(IOBuffer *) ibuffer;
+ (long long) readLong:(IOBuffer *) ibuffer;
+ (NSMutableArray *) readLongArray:(IOBuffer *) ibuffer;
+ (float) readFloat:(IOBuffer *) ibuffer;
+ (NSMutableArray *) readFloatArray:(IOBuffer *) ibuffer;
+ (double) readDouble:(IOBuffer *) ibuffer;
+ (NSMutableArray *) readDoubleArray:(IOBuffer *) ibuffer;
+ (NSString*) readString:(IOBuffer *) ibuffer;
+ (NSMutableArray *) readStringArray:(IOBuffer *) ibuffer;

+ (void) writeByte:(IOBuffer *) obuffer :(Byte) v;
+ (void) writeByteArray:(IOBuffer *) obuffer :(NSMutableArray *) ary;
+ (void) writeBoolean:(IOBuffer *) obuffer :(BOOL) v;
+ (void) writeBooleanArray:(IOBuffer *) obuffer :(NSMutableArray *) ary;
+ (void) writeShort:(IOBuffer *) obuffer :(short) v;
+ (void) writeShortArray:(IOBuffer *) obuffer :(NSMutableArray *) ary;
+ (void) writeInteger:(IOBuffer *) obuffer :(int) v;
+ (void) writeIntegerArray:(IOBuffer *) obuffer :(NSMutableArray *) ary;
+ (void) writeLong:(IOBuffer *) obuffer :(long long) v;
+ (void) writeLongArray:(IOBuffer *) obuffer :(NSMutableArray *) ary;
+ (void) writeFloat:(IOBuffer *) obuffer :(float) v;
+ (void) writeFloatArray:(IOBuffer *) obuffer :(NSMutableArray *) ary;
+ (void) writeDouble:(IOBuffer *) obuffer :(double) v;
+ (void) writeDoubleArray:(IOBuffer *) obuffer :(NSMutableArray *)ary;
+ (void) writeString:(IOBuffer *) obuffer :(NSString *) v;
+ (void) writeStringArray:(IOBuffer *) obuffer :(NSMutableArray *) ary;

@end

@interface NullMessageBean : MessageBean {
}
@end

///////////////////////////////////////////////////////////////////////////////
@class Prop;
@class Backpack;
@class AllType;
@class SceneMap;
@class CommandResponse;

///////////////////////////////////////////////////////////////////////////////
// 消息Prop
// Message Compiler 测试用例
// 道具
//
@interface Prop : MessageBean {
	// 道具编号
	// 原型: int id;
	int ID;
	
	// 道具名称
	// 原型: String name;
	NSString* name;
	
	// 道具类型
	// 原型: byte type;
	Byte type;
	
	// 道具显示图标编号
	// 原型: short icon;
	short icon;
	
	// 道具数量
	// 原型: long quantity;
	long long quantity;
	
	// 道具图像PNG流
	// 原型: byte[] image;
	NSMutableArray* image;
	
}

@property int ID;
@property (readonly, assign) NSString* name;
@property Byte type;
@property short icon;
@property long long quantity;
@property (readonly, assign) NSMutableArray* image;

- (void) setName:(NSString *) str;
- (void) setNameWithCString:(const char *) str;
- (NSUInteger) getNameToCString:(char *)str :(int) maxLen;
- (void) addElementToImage:(Byte) elem;
- (void) setImage:(NSMutableArray *) array;
- (void) setImageWithArray:(Byte *) ary :(int) len;
- (int) getImageToArray:(Byte *) ary;

@end

///////////////////////////////////////////////////////////////////////////////
// 消息Backpack
// 玩家背包
// 服务器下发玩家背包中的详细物品列表
//
@interface Backpack : MessageBean {
	// 测试ASCII字符串
	// 原型: String asciiString;
	NSString* asciiString;
	
	// 测试中文字符串
	// 多行Javadoc是否OK？
	// 原型: String chineseString;
	NSString* chineseString;
	
	// 角色ID
	// 原型: int characterId;
	int characterId;
	
	// 背包中的物品列表
	// 原型: List<Prop> props;
	NSMutableArray* props;
	
}

@property (readonly, assign) NSString* asciiString;
@property (readonly, assign) NSString* chineseString;
@property int characterId;
@property (readonly, assign) NSMutableArray* props;

- (void) setAsciiString:(NSString *) str;
- (void) setAsciiStringWithCString:(const char *) str;
- (NSUInteger) getAsciiStringToCString:(char *)str :(int) maxLen;
- (void) setChineseString:(NSString *) str;
- (void) setChineseStringWithCString:(const char *) str;
- (NSUInteger) getChineseStringToCString:(char *)str :(int) maxLen;
- (void) addElementToProps:(Prop*) elem;
- (void) setProps:(NSMutableArray *) array;

@end

///////////////////////////////////////////////////////////////////////////////
// 消息AllType
// Message Compiler 测试用例
// 测试所有可能的数据类型
//
@interface AllType : MessageBean {
	// 原型: byte byteValue;
	Byte byteValue;
	
	// 原型: byte[] byteArray;
	NSMutableArray* byteArray;
	
	// 原型: boolean boolValue;
	BOOL boolValue;
	
	// 原型: boolean[] boolArray;
	NSMutableArray* boolArray;
	
	// 原型: short shortValue;
	short shortValue;
	
	// 原型: short[] shortArray;
	NSMutableArray* shortArray;
	
	// 原型: int intValue;
	int intValue;
	
	// 原型: int[] intArray;
	NSMutableArray* intArray;
	
	// 原型: long longValue;
	long long longValue;
	
	// 原型: long[] longArray;
	NSMutableArray* longArray;
	
	// 原型: float floatValue;
	float floatValue;
	
	// 原型: float[] floatArray;
	NSMutableArray* floatArray;
	
	// 原型: double doubleValue;
	double doubleValue;
	
	// 原型: double[] doubleArray;
	NSMutableArray* doubleArray;
	
	// 原型: String stringValue;
	NSString* stringValue;
	
	// 原型: String[] stringArray;
	NSMutableArray* stringArray;
	
	// 原型: Prop prop;
	Prop* prop;
	
	// 原型: List<Prop> propList;
	NSMutableArray* propList;
	
}

@property Byte byteValue;
@property (readonly, assign) NSMutableArray* byteArray;
@property BOOL boolValue;
@property (readonly, assign) NSMutableArray* boolArray;
@property short shortValue;
@property (readonly, assign) NSMutableArray* shortArray;
@property int intValue;
@property (readonly, assign) NSMutableArray* intArray;
@property long long longValue;
@property (readonly, assign) NSMutableArray* longArray;
@property float floatValue;
@property (readonly, assign) NSMutableArray* floatArray;
@property double doubleValue;
@property (readonly, assign) NSMutableArray* doubleArray;
@property (readonly, assign) NSString* stringValue;
@property (readonly, assign) NSMutableArray* stringArray;
@property (readonly, assign) Prop* prop;
@property (readonly, assign) NSMutableArray* propList;

- (void) addElementToByteArray:(Byte) elem;
- (void) setByteArray:(NSMutableArray *) array;
- (void) setByteArrayWithArray:(Byte *) ary :(int) len;
- (int) getByteArrayToArray:(Byte *) ary;
- (void) addElementToBoolArray:(BOOL) elem;
- (void) setBoolArray:(NSMutableArray *) array;
- (void) setBoolArrayWithArray:(BOOL *) ary :(int) len;
- (int) getBoolArrayToArray:(BOOL *) ary;
- (void) addElementToShortArray:(short) elem;
- (void) setShortArray:(NSMutableArray *) array;
- (void) setShortArrayWithArray:(short *) ary :(int) len;
- (int) getShortArrayToArray:(short *) ary;
- (void) addElementToIntArray:(int) elem;
- (void) setIntArray:(NSMutableArray *) array;
- (void) setIntArrayWithArray:(int *) ary :(int) len;
- (int) getIntArrayToArray:(int *) ary;
- (void) addElementToLongArray:(long long) elem;
- (void) setLongArray:(NSMutableArray *) array;
- (void) setLongArrayWithArray:(long long *) ary :(int) len;
- (int) getLongArrayToArray:(long long *) ary;
- (void) addElementToFloatArray:(float) elem;
- (void) setFloatArray:(NSMutableArray *) array;
- (void) setFloatArrayWithArray:(float *) ary :(int) len;
- (int) getFloatArrayToArray:(float *) ary;
- (void) addElementToDoubleArray:(double) elem;
- (void) setDoubleArray:(NSMutableArray *) array;
- (void) setDoubleArrayWithArray:(double *) ary :(int) len;
- (int) getDoubleArrayToArray:(double *) ary;
- (void) setStringValue:(NSString *) str;
- (void) setStringValueWithCString:(const char *) str;
- (NSUInteger) getStringValueToCString:(char *)str :(int) maxLen;
- (void) addElementToStringArray:(NSString*) elem;
- (void) setStringArray:(NSMutableArray *) array;
- (void) setProp:(Prop *) ref;
- (void) addElementToPropList:(Prop*) elem;
- (void) setPropList:(NSMutableArray *) array;

@end

///////////////////////////////////////////////////////////////////////////////
// 消息SceneMap
// 地图数据
//
@interface SceneMap : MessageBean {
	// 地图编号
	// 原型: int id;
	int ID;
	
	// 原型: byte[] data;
	NSMutableArray* data;
	
	// 测试单个Bean
	// 原型: Prop prop;
	Prop* prop;
	
}

@property int ID;
@property (readonly, assign) NSMutableArray* data;
@property (readonly, assign) Prop* prop;

- (void) addElementToData:(Byte) elem;
- (void) setData:(NSMutableArray *) array;
- (void) setDataWithArray:(Byte *) ary :(int) len;
- (int) getDataToArray:(Byte *) ary;
- (void) setProp:(Prop *) ref;

@end

///////////////////////////////////////////////////////////////////////////////
// 消息CommandResponse
//
@interface CommandResponse : MessageBean {
	// 错误码
	// 原型: int errorCode;
	int errorCode;
	
	// 错误信息
	// 原型: String errorMessage;
	NSString* errorMessage;
	
}

@property int errorCode;
@property (readonly, assign) NSString* errorMessage;

- (void) setErrorMessage:(NSString *) str;
- (void) setErrorMessageWithCString:(const char *) str;
- (NSUInteger) getErrorMessageToCString:(char *)str :(int) maxLen;

@end

